const path = require('path');

function resolve(dir) {
  return path.join(__dirname, dir);
}

module.exports = {
  publicPath: '/',
  lintOnSave: true,
  productionSourceMap: false,
  chainWebpack: config => {
    config.resolve.alias
        .set('@components', resolve('src/components'))
        .set('@assets', resolve('src/assets'))
        .set('@picture', resolve('src/assets/picture'))
        .set('@common', resolve('src/common'))
        .set('@store', resolve('src/store'))
        .set('@router', resolve('src/router'))
        .set('@', resolve('src'));
  },
  devServer: {
    // 设置代理
    proxy: {
      '/gaode': {
        target: 'https://restapi.amap.com', //访问地址
        changeOrigin: true,
        pathRewrite: {
          '^/gaode': ''
        }
      },
      '/api': {
        target: 'http://127.0.0.1:3000',
      }
    },
    hot: false, // 禁用 HMR
    disableHostCheck: true, // 禁用 host 检查，防止 sockjs-node 报错
    headers: { 'Access-Control-Allow-Origin': '*' },
    overlay: false, // 禁用编译错误显示在浏览器上
  }
};
